package com.example.blogsystem.config;

import com.example.blogsystem.enums.ResultCodeEnum;
import com.example.blogsystem.model.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;


//统一异常返回
@Slf4j
@RestControllerAdvice
public class ExceptionAdvice {
   /* @ExceptionHandler
    public Result handler(Exception e) {
        log.error("发生异常e"+e);
        return Result.fail(e.getMessage());
    }*/
    @ExceptionHandler
    public Result handler(IllegalArgumentException e) {
        log.error("参数为空");
        return Result.fail(e.getMessage());
    }
    @ExceptionHandler
    public Result hander(UnsupportedOperationException e) {
        log.error("参数为空");
        return Result.fail(ResultCodeEnum.PARAM_INVILD.getCode(),e.getMessage());
    }
}
